var mongoose = require('mongoose');
var config = require('../config').config;
var logger = require('../service/Logger');
    mongoose.connect(config.db, function(err){
        if(err){
            logger.error('connect to fanju DB Error:' + err.message);
            process.exist();
        }else{
            logger.debug('connect to fanju DB suceess!')
        }
    });

//models
require('./User');
require('./Activity');
require('./Card');
require('./Relation');
require('./Suggest');
require('./Faction');
require('./Creditspolicy');
require('./Topic');
require('./FactionMember');
require('./LogRecord');
require('./Goods');
require('./Order');

exports.User = mongoose.model('User');
exports.Activity = mongoose.model('Activity');
exports.Card = mongoose.model('Card');
exports.Relation = mongoose.model('Relation');
exports.Suggest = mongoose.model('Suggest');
exports.Faction = mongoose.model('Faction');
exports.Goods = mongoose.model('Goods');
exports.Order = mongoose.model('Order');
exports.Creditspolicy = mongoose.model('Creditspolicy');
exports.Topic = mongoose.model('Topic');
exports.FactionMember = mongoose.model('FactionMember');
exports.LogRecord = mongoose.model('LogRecord');
exports.ObjectId = mongoose.Schema.Types.ObjectId;
exports.GridStore = mongoose.mongo.GridStore;
exports.DB = mongoose.connection.db;